#@head() #@header()
<title>客户列表</title>
#@aside("custser")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<style>
	.box-body{padding:5px !important}
</style>
<div class="content-wrapper">
	<section class="content">
	<div class="nav-tabs-custom">
		<ul class="nav nav-tabs">
			<li class="active"><a href="#(path)/admin/page/auxiliary-customlist" >知识库</a></li>
		</ul>
		 <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				<button type="button" onclick="window.location.href='#(path)/admin/page/custser-addrepository'" class="btn btn-block btn-info" style="width:120px;float:left;margin-top:10px;margin-right:20px;">新建词条</button>
				<div class="input-group margin" style="width:60%;float:left">
					<input type="text" id="key2" class="form-control" >
					<span class="input-group-btn"> 
					  <button id="keyseach2" type="button" class="btn btn-info btn-flat">搜索</button>
					</span>
				</div>
				<div class="box-body">
					<table id="example1" class="table table-striped">
						<thead>
							<tr>
								<th>ID</th>
								<th>标题</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="newslist">
						</tbody>
					</table>
				</div>
				<div class="box-footer clearfix">
				  <ul class="pagination pagination-sm no-margin pull-right">
					<li id="newslist1"><a href="#">首页</a></li>
					<li id="newslist2"><a href="#">上一页</a></li>
					<li><a href="#">第<span id="newslist5"></span>页 共<span id="newslist6"></span>页</a></li>
					<li id="newslist3"><a href="#">下一页</a></li>
					<li id="newslist4"><a href="#">尾页</a></li>
				  </ul>
				</div>
              </div>
            </div>
            <!-- /.tab-content -->
          </div>
		  
	</section>
</div>
#@footer()
<script id="newslistall" type="text/x-jquery-tmpl">
	<tr>
		<td>${id}</td>
		<td><a href=${href}>${name}</a></td>
		<td>
			<div class="btn-group">
			  <div class="btn-group">
			  <button onclick="window.location.href='#(path)/admin/page/custser-changerepos?id=${id}'" type="button" class="btn btn-info">修改</button>
			</div>
			</div>
		</td>
	</tr>
</script>
<script>
var totalPage = 1;
var pageNumber = 1;
var key2 = "";
 $(document).ready(function(){
	totalPage = 1;
	pageNumber = 1;
	$("#newslist").empty();
	newslist(1);
	$("#newslist5").html(pageNumber);
});
$("#newslist1").click(function(){
	$("#newslist").empty();
	newslist(1);
	pageNumber = 1;
	$("#newslist5").html(pageNumber);
});
$("#newslist2").click(function(){
	if(pageNumber==1){
		alert("当前页是首页!");
	}else{
	$("#newslist").empty();
	pageNumber = pageNumber-1;
	newslist(pageNumber);
	$("#newslist5").html(pageNumber);
	}
});
$("#newslist3").click(function(){
	if(pageNumber==totalPage){
		alert("当前页是尾页!");
	}else{
	$("#newslist").empty();
	pageNumber = pageNumber +1;
	newslist(pageNumber);
	$("#newslist5").html(pageNumber);
	}
});
$("#newslist4").click(function(){
	$("#newslist").empty();
	newslist(totalPage);
	pageNumber = totalPage;
	$("#newslist5").html(pageNumber);
});
$("#keyseach2").click(function(){
	totalPage = 1;
	pageNumber = 1;
	$("#newslist").empty();
	key2 = $("#key2").val();
	newslist(1);
	$("#newslist5").html(pageNumber);
});
function newslist(page){
	$.getJSON("/notice/search?token=#(session.token??)&type=repository&page="+page+"&size=12&key="+key2, function(userli) {
		
		totalPage = userli.data.page.totalPage;
		$("#newslist6").html(totalPage);
		$.each(userli.data.page.list, function(i, item){ 
			var href="#(path)/admin/page/custser-repositoryinfo?id="+item.id;
			var newslist = {href:href,name:item.name,status:status,id:item.id,create_time:item.create_time};
			$("#newslistall").tmpl(newslist).appendTo('#newslist');
		});
		$(".pass").click(function(){
			var idval = $(this).attr("pass");
			var bb="";
			var aa=$(this).html();
			
			if(aa=="上线"){ bb = "enable"}else if(aa=="下线"){ bb = "disable"}
			
			$.getJSON("/notice/switchStatus?token=#(session.token??)&id="+idval+"&status="+bb, function(data) {
				if(data.code=='success'){
					layer.msg(data.msg, {icon:1},function(){
						location.href="#(path)/admin/page/custser-repository"
					});
				}else if(data.code=='error'){
					layer.msg(data.msg, {icon:2});
				}
			});
		});
	});	
}
</script> 


</body>
</html>

